﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace autoBidProject
{
    class League
    {
        private string name;

       
        private List<Match> matchs;

        
        public League(string name)
        {
            this.name = name;
            this.matchs = new List<Match>();
        }

        public void Add(Match match)
        {
            this.matchs.Add(match);
        }

        internal void Add(Event e)
        {
            foreach (Match match in matchs)
                if (e.Name().CompareTo(match.Name()) == 0)
                {
                    match.Add(e);
                    return;
                }
            Match newMatch = new Match(e.name_home, e.name_away);
            newMatch.Add(e);
            matchs.Add(newMatch);
        }

        public Match GetMatch(string name)
        {
            foreach (Match match in matchs)
                if (match.Name().CompareTo(name) == 0)
                    return match;
            return null;
        }

        internal List<Match> Matchs
        {
            get { return matchs; }
            set { matchs = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }


        internal int CountMatch()
        {
            return matchs.Count;
        }
    }
}
